<template>
	<view>
		<!-- 会员卡盒子 -->
		<view class="vip_box">
			<view class="mdlvip">牡丹链会员卡</view>
			<view class="kh_box">
				<text class="kahao">卡号:</text>
				<text class="number">{{dataList.card_num}}</text>
			</view>
			<view class="daoqi">{{dataList.expirydate}}到期</view>
			<view class="jifen">
				<text>已释放{{dataList.release_num}}贡献值</text>
				<text style="padding-left: 55rpx;">可用{{dataList.residual_num}}贡献值</text>
			</view>
		</view>
		<!-- 商品列表 -->
		<!-- <view style="display: flex; flex-wrap: wrap;">
			<view class="product_box" v-for="(item,index) in productList" :key='index' @click="goProduct(item)">
				<view class="product_img">
					<image :src="item.picture" style="height: 330rpx; width: 330rpx; ;" mode="widthFix"></image>
				</view>
				
				<view class="product_name">{{item.name}}</view>
				<view class="product_price">￥{{item.price}}</view>
			</view>
		</view> -->
		<!-- 贡献值明细 -->
		<view class="gongxian_box">
			<view class="gongxian_name">贡献值明细</view>
			<view class="gongxian_details" v-for="(item,index) in contribution" :key="index">
				<view class="gongxian_style">{{item.remark}}</view>
				<view>
					<view class="gongxian_num">{{item.num}}贡献值</view>
					<view class="gongxian_time">{{item.create_at}}</view>
				</view>
			</view>
		</view>	
		
	</view>
</template>

<script>
	import {vipProduct,cardRecord} from "@/api/product";
	import {memberCard} from '@/api/userInfo';
	export default {
		data(){
			return{
				dataList:'',
				productList:[],
				isLoad:true,
				num:0,
				contribution:[]
			}
		},
		methods:{
			goProduct(item){
				uni.navigateTo({
					url:"/pages/product/product?id="+item.id
				})
			},
			getInfo(){
				this.num++;
				this.$get(vipProduct,{page:this.num}).then(r=>{
					// console.log(r);
					r.data.forEach(item=>{
						this.productList.push(item);
					})
					if(r.data.length<10){
						this.isLoad=false;
					}
				})
			},
			getDetails(){
				this.num++;
				this.$get(cardRecord,{page:this.num}).then(res=>{
					console.log(res);
					// this.contribution=res.data;
					res.data.forEach(it=>{
						this.contribution.push(it);
					})
					if(res.data.length<10){
						this.isLoad=false;
					}
				})
			}
		},
		onLoad() {
			this.$post(memberCard).then(res=>{
				console.log(res);
				this.dataList=res.data;
			})
			// this.getInfo();
			this.getDetails();
			
		},
		onReachBottom() {
			if(this.isLoad==true){
				this.getDetails();
			}
		}
	}
</script>

<style>
	.vip_box{
		padding-left: 20rpx;
		width: 690rpx;
		height: 295rpx;
		margin: 30rpx auto;
		background-image: url(../../../static/vip_bg.png);
		background-repeat: no-repeat;
		background-size: 690rpx;
	}
	.mdlvip{
		padding-top: 20rpx;
		font-size: 36rpx;
		font-weight: 300;
		color: #999999;
	}
	.kh_box{
		margin-top: 15rpx;
	}
	.kahao{
		font-size: 32rpx;
		font-weight: 400;
		color: #999999;
	}
	.number{
		font-size: 32rpx;
		font-weight: 400;
		color: #F5C362;
		padding-left: 20rpx;
	}
	.daoqi{
		font-size: 26rpx;
		font-weight: 600;
		color: #F5C362;
		margin-top: 15rpx;
	}
	.jifen{
		margin-top: 15rpx;
		font-size: 22rpx;
		font-weight: 300;
		color: #999999;
	}
	.product_box{
		width: 330rpx;
		height: 458rpx;
		border-radius: 8rpx;
		background-color: #dfdfdf;
		margin-left: 30rpx;
		margin-bottom: 20rpx;
	}
	.product_img{
		height: 330rpx;
		overflow: hidden
	}
	.product_name{
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
		padding-left: 20rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333333;
		margin-top: 20rpx;
	}
	.product_price{
		padding-left: 20rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #F5C362;
	}
	.gongxian_box{
		width: 690rpx;
		margin: 30rpx auto;
		background-color: #FFFFFF;
		border-radius: 12rpx;
		padding: 30rpx;
	}
	.gongxian_name{
		font-size: 30rpx;
		font-weight: 600;
		color: #111111;
	}
	.gongxian_details{
		border-bottom: 2rpx solid #DFDFDF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 8rpx;
	}
	.gongxian_style{
		font-size: 30rpx;
		font-weight: 300;
		color: #333333;
	}
	.gongxian_num{
		font-size: 26rpx;
		font-weight: 600;
		color: #E1251B;
		text-align: right;
	}
	.gongxian_time{
		font-size: 18rpx;
		font-weight: 300;
		color: #333333;
	}
</style>
